#include <ros/ros.h>
#include <iostream>
#include "lcm/lcm-cpp.hpp"
#include "exlcm/example_t.hpp"

 #ifndef PRId64
#define PRId64 "lld"
#endif
class MyMessageHandler 
{
public:
  void onMessage(const lcm::ReceiveBuffer* rbuf,const std::string& chan,const exlcm::example_t* msg)
    {
	    int i;
    printf("Received message on channel \"%s\":\n", chan);
    printf("  timestamp   = %d\n", msg->timestamp);
    printf("  position    = (%f, %f, %f)\n",
            msg->position[0], msg->position[1], msg->position[2]);
    printf("  orientation = (%f, %f, %f, %f)\n",
            msg->orientation[0], msg->orientation[1], msg->orientation[2],
            msg->orientation[3]);
    printf("  ranges:");
    for(i = 0; i < 15; i++)
        printf(" %d", msg->ranges[i]);
    printf("\n");
    //printf("  name        = '%s'\n", msg->name);
    printf("  enabled     = %d\n", msg->enabled);
        }
};
 
int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_publisher");
  ros::NodeHandle nh;
 
  lcm::LCM lcm;
  MyMessageHandler handler;

  lcm.subscribe("LCM_Send", &MyMessageHandler::onMessage, &handler);
  while (true)
    lcm.handle();
 
  ros::spin();
}
